import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';

class SwiperPage extends StatefulWidget {
  SwiperPage({Key key}) : super(key: key);

  @override
  _SwiperPageState createState() => _SwiperPageState();
}

class _SwiperPageState extends State<SwiperPage> {

  List<Map> imgList =[
   {
    'url': 'https://images.weserv.nl/?url=img1.doubanio.com/view/photo/m/public/p2636695009.webp'
   },
   {
    'url': 'https://images.weserv.nl/?url=img1.doubanio.com/view/photo/m/public/p2636695009.webp'
   },
   {
    'url': 'https://images.weserv.nl/?url=img1.doubanio.com/view/photo/m/public/p2636695009.webp'
   },
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('Swiper'),
        ),
        body: Column(
          children: <Widget>[
            Container(
              width: double.infinity,
              child: AspectRatio(
                aspectRatio: 16/9,
                child: 
                //   Swiper(
                //   itemBuilder: (BuildContext context, int index) {
                //     return new Image.network(
                //       imgList[index]['url'],
                //       fit: BoxFit.fill,
                //     );
                //   },
                //   autoplay: true,
                //   itemCount: imgList.length,
                //   pagination: new SwiperPagination(),
                //   control: new SwiperControl(), // 左右箭头
                //   loop: true,
                // ),
                new Swiper(
                  itemBuilder: (BuildContext context,int index){
                    return new Image.network(
                      imgList[index]['url'],
                      fit: BoxFit.fill,
                    );
                  },
                  itemCount: imgList.length,
                  pagination: new SwiperPagination(),
                  control: new SwiperControl(),
                  // viewportFraction: 0.8,
                  scale: 0.9,

                  // itemWidth: 300.0,
                  // layout: SwiperLayout.STACK,

                  itemWidth: 300.0,
                  itemHeight: 400.0,
                  layout: SwiperLayout.TINDER,

                ),
              ),
            )
          ],
        )
      );
  }
}